<?php


namespace addons\Minerva\api\modules\v1\controllers;


use addons\Desktop\common\models\DesktopTest;
use api\controllers\OnAuthController;
use common\models\backend\Member;
use Curl\Curl;
use yii\data\ActiveDataProvider;

class MemberController extends OnAuthController
{
    /**
     * @var Member
     */
    public $modelClass = Member::class;

    /**
     * 不用进行登录验证的方法
     *
     * 例如： ['index', 'update', 'create', 'view', 'delete']
     * 默认全部需要验证
     *
     * @var array
     */
    protected $authOptional = ['test'];

    public function actionIndex(){

        $list = new ActiveDataProvider([
            'query' => Member::find()
//                ->where(['userid' => $member_id])
                ->orderBy('created_at desc')
//                ->select('id,jiben_name,jiben_idcard,created_at,state')
                ->asArray(),
            'pagination' => [
                'pageSize' => $this->pageSize,
                'validatePage' => false,// 超出分页不返回data
            ],
        ]);
        return $list;
    }

    public function actionTest(){
//        $str = 'appId=doormen&nonceStr=z7cl7WR9&time=1629800258e3de3825cfbf';
//        $sign = strtolower(md5($str));
//        // 555679a7613dadf6645427fb900fd8ea
//        return $sign;

        $curl = new Curl();
//        $res1 = $curl->getResponseHeaders('http://cl.fhdianshang.com/api/minerva/v1/ftp/index?access-token=rbnj4FyDyujCF2KCVse13jowsT8IjqfB_1633918775');
        $res2 = $curl->get('http://cl.fhdianshang.com/api/minerva/v1/ftp/index?access-token=rbnj4FyDyujCF2KCVse13jowsT8IjqfB_1633918775');
        return $curl->getResponseHeaders();
    }
}